﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EF.Oracle.Sql
{

    public class SqlServerDbContext : DbContext
    {
        public SqlServerDbContext() : base("SqlServer") { }

        public DbSet<Category> Categories { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Category>().HasKey(k => k.CategoryId) //设置主键
                .Property(q => q.CategoryName).IsRequired();//设置不能为空

            modelBuilder.HasDefaultSchema("YANGZJ");
        }
    }
}
